function popShow(id) {
    $(id + "").fadeIn();
}

function popHide(id) {
    $(id + "").fadeOut();
}

//禁止页面滑动
$('.index').on('touchmove', function(event) {
    event.preventDefault();
});


/*阻止用户双击使屏幕上滑*/
var agent = navigator.userAgent.toLowerCase(); //检测是否是ios
var iLastTouch = null; //缓存上一次tap的时间
if (agent.indexOf('iphone') >= 0 || agent.indexOf('ipad') >= 0) {
    document.body.addEventListener('touchend', function(event) {
        var iNow = new Date()
            .getTime();
        iLastTouch = iLastTouch || iNow + 1 /** 第一次时将iLastTouch设为当前时间+1 */ ;
        var delta = iNow - iLastTouch;
        if (delta < 500 && delta > 0) {
            event.preventDefault();
            return false;
        }
        iLastTouch = iNow;
    }, false);
}

//防止微信输入后页面顶起
function temporaryRepair() {
    var currentPosition, timer;
    var speed = 1; //页面滚动距离
    timer = setInterval(function() {
        currentPosition = document.documentElement.scrollTop || document.body.scrollTop;
        currentPosition -= speed;
        window.scrollTo(0, currentPosition); //页面向上滚动
        currentPosition += speed; //speed变量
        window.scrollTo(0, currentPosition); //页面向下滚动
        clearInterval(timer);
    }, 1);
}

$('.name,.tel,.day,.adviser').blur(function() {
    temporaryRepair();
})

//背景音乐
var audio = document.getElementById('music');

function change() {
    if (audio.paused) {
        audio.play();
        $(".audio").addClass('reg')
    } else {
        audio.pause();
        $(".audio").removeClass('reg')
    }
}

function audioAutoPlay(id) {
    var audio = document.getElementById(id);
    audio.play();
    document.addEventListener("WeixinJSBridgeReady", function() {
        audio.play();
    }, false);
    document.addEventListener('YixinJSBridgeReady', function() {
        audio.play();
    }, false);
}
audioAutoPlay('music');


//流量统计
var _mtac = {};
(function() {
    var mta = document.createElement("script");
    mta.src = "//pingjs.qq.com/h5/stats.js?v2.0.4";
    mta.setAttribute("name", "MTAH5");
    mta.setAttribute("sid", "500674651");
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(mta, s);
})();